package com.nsl.my_youlai.bbu_return.convert.enums;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.nsl.my_youlai.bbu_return.enums.VendorEnum;
import com.nsl.my_youlai.mystar.enums.NslEnumBaseI;

public class VendorEnumConvert implements Converter<VendorEnum> {

    @Override
    public Class<VendorEnum> supportJavaTypeKey() {
        return VendorEnum.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }



    @Override
    public VendorEnum convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {

        return NslEnumBaseI.getEnumByLabel(cellData.getStringValue(),VendorEnum.class);


    }


    //导出时转换
    @Override
    public WriteCellData<VendorEnum> convertToExcelData(VendorEnum value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration)  {

        WriteCellData<VendorEnum> writeCellData=new WriteCellData<>(CellDataTypeEnum.STRING,value.getLabel());
        return writeCellData;
    }
}
